﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Utils.DatabaseUtils;
using Utils;
using System.Data;

namespace Entity
{
    public class ImagesUI
    {
        int _I_ID;

        public int I_ID
        {
            get { return _I_ID; }
            set { _I_ID = value; }
        }
        string _I_Name;

        public string I_Name
        {
            get { return _I_Name; }
            set { _I_Name = value; }
        }
        string _I_URL;

        public string I_URL
        {
            get { return _I_URL; }
            set { _I_URL = value; }
        }
        bool _I_StatusDelete;

        public bool I_StatusDelete
        {
            get { return _I_StatusDelete; }
            set { _I_StatusDelete = value; }
        }
        int _cusid;

        public int Cusid
        {
            get { return _cusid; }
            set { _cusid = value; }
        }


        public int Add(string I_Name,string I_URL,bool I_StatusDelete,int cusid)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "Images_add", I_Name, I_URL, I_StatusDelete, cusid);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public int Delete(int Images_ID)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "Images_delete", Images_ID);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public DataSet Get(int Images_ID)
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "Images_get", Images_ID);
                return result;
            }
            catch (Exception e) { return null; }
        }

        public DataSet GetByCusID(int cusid)
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "Images_getbycusid", cusid);
                return result;
            }
            catch (Exception e) { return null; }
        }

        public DataSet GetAll()
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "Images_getall");
                return result;
            }
            catch (Exception e) { return null; }
        }

        public int Update(string Size_Name, float Price)
        {
            try
            {
                int result = SqlHelper.ExecuteNonQuery(Common.Conn, "Size_update", Size_Name, Price);
                return result;
            }
            catch (Exception ex)
            {
                return -1;
            }
        }

        public DataSet Statistic()
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "Images_statistic");
                return result;
            }
            catch (Exception ex)
            {
                return null;
            }
        }

        public DataSet CheckExists(string I_Name,int cusid)
        {
            try
            {
                DataSet result = SqlHelper.ExecuteDataset(Common.Conn, "Images_CheckExists", I_Name,cusid);
                return result;
            }
            catch (Exception e) { return null; }
        }

    }
}
